//创建读出流
var fs = require('fs');

var stream1=fs.createReadStream('./data.txt');

stream1.on('data',function (txt) {
    console.log(txt);
});
//读取完成事件
stream1.on('end',function () {
    console.log('文件读取完毕');
});
//读取出错事件
stream1.on('error',function () {
    console.log('文件读取失败');
});